/* Copyright (c) 2004-2024 peigen.info. All rights reserved. */

package info.peigen.hotpot.manage.core.service.processor.login;

import cn.dev33.satoken.stp.StpUtil;
import info.peigen.hotpot.common.service.base.processor.Processor;
import info.peigen.hotpot.common.service.base.processor.ProcessorServiceContext;
import info.peigen.hotpot.manage.core.domain.User;
import info.peigen.hotpot.manage.core.service.processor.AbstractHotpotManageServiceProcessor;
import org.noear.solon.annotation.Component;

/**
 * <b>(LoginTokenProcessor)</b>
 * 登陆Token生成
 *
 * @author Peigen
 * @version 1.0.0
 * @since 2024/7/24
 */
@SuppressWarnings("rawtypes")
@Component
public class LoginTokenProcessor extends AbstractHotpotManageServiceProcessor implements Processor {
    @Override
    public Integer level() {
        return 99;
    }

    @Override
    public void execute(ProcessorServiceContext serviceContext) {
        User domain = (User) serviceContext.getDomain();
        domain.check();
        StpUtil.login(domain.getUserId());
        String token = StpUtil.getTokenValue();
        serviceContext.getResult().setToken(token);
    }

}